import request from '../service/api';

export default {
    namespace: 'recharge',
    state: {
      current: 0,
      tradeList: []
    },
    effects: {
        * init(_, {call, put}) {
            const {data: {data = [], code } = {}} = yield call(() => request.post('/mini/order-pay/findTransactionRecord', {
                pageNum: 1,
                pageSize: 9999
            }));
          console.log('交易记录', data);
            if (code && code === 200){
              yield put({
                type: 'setState',
                payload: {
                  tradeList: data?.records.length ? data.records.reverse() : [] // 按照交易时间降序排列
                }
              })
            }
        }
    },
    reducers: {
        setState(state, {payload}) {
            return {
                ...state,
                ...payload
            }
        }
    }
}
